Mahout source code modification and re-compile

Mahout source code modification and re-compile

author: sheng junhui

weibo: @armysheng

blog: youngfor.me

email: armysheng@gmail.com

1.unzip your downloaded mahout src file mahout-distribution-0.9-src, import this maven project to eclipse;

2.new a test class at project mahout-core with package name org.apache.mahout.test,name modifytest.java;

3.implement this modifytest class with code as follows:

package org.apache.mahout.test;

public class modifytest {
	public static void hello(){
		System.out.println("modifytest success !");
	}
}

4.re-compile the project by right click the pom.xml of mahout-core project, choose Run as + Maven build and fill the goal option with -DskipTests clean install, then the compile starts and it will take few minutes.

After successful compliation you should see:

[INFO] Building jar: D:\workspace\Mahout\mahout-distribution-0.9\core\target\mahout-core-0.9-sources.jar
[INFO] 
[INFO] --- maven-install-plugin:2.5.1:install (default-install) @ mahout-core ---
[INFO] Installing D:\workspace\Mahout\mahout-distribution-0.9\core\target\mahout-core-0.9.jar to C:\Users\shengjh\.m2\repository\org\apache\mahout\mahout-core\0.9\mahout-core-0.9.jar
[INFO] Installing D:\workspace\Mahout\mahout-distribution-0.9\core\pom.xml to C:\Users\shengjh\.m2\repository\org\apache\mahout\mahout-core\0.9\mahout-core-0.9.pom
[INFO] Installing D:\workspace\Mahout\mahout-distribution-0.9\core\target\mahout-core-0.9-tests.jar to C:\Users\shengjh\.m2\repository\org\apache\mahout\mahout-core\0.9\mahout-core-0.9-tests.jar
[INFO] Installing D:\workspace\Mahout\mahout-distribution-0.9\core\target\mahout-core-0.9-job.jar to C:\Users\shengjh\.m2\repository\org\apache\mahout\mahout-core\0.9\mahout-core-0.9-job.jar
[INFO] Installing D:\workspace\Mahout\mahout-distribution-0.9\core\target\mahout-core-0.9-sources.jar to C:\Users\shengjh\.m2\repository\org\apache\mahout\mahout-core\0.9\mahout-core-0.9-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45.205 s
[INFO] Finished at: 2014-06-11T13:57:27+08:00
[INFO] Final Memory: 25M/124M
[INFO] ------------------------------------------------------------------------

After this step, we have added a new class in mahout source code at mahout-core. Now let's see if it works.

5.build a new simple maven project with eclipse named modifytest or others, add the mahout dependency into the pom.xml file.

<dependencies>
<dependency>
    <groupId>org.apache.mahout</groupId>
    <artifactId>mahout-core</artifactId>
    <version>0.9</version>
</dependency>
</dependencies>

add a new class named test.java to this project and implement with code:

	package com.docomo.muc.mahoutlearning;

	import org.apache.mahout.test.modifytest;

	public class test {
		public static void main(String[] args){
			modifytest tt= new modifytest();
			tt.hello();
		}
	}

Hit crtl+F11 to run this project, and we can see the print output:

	modifytest success !
请我喝杯咖啡吧!